﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace SimplePlanner.Entity
{
    public class Period
    {
        public DayTime startTime;
        public DayTime endTime;
        public int day;
        public int week;
        public Period() { }
        public Period(DayTime a, DayTime b, int d, int w = 0)
        {
            startTime = a;
            endTime = b;
            week = w;
            day = d;
        }

        public static bool overlap(Period a, Period b)
        {
            if ((a.week == 1 && b.week == 2) ||
                (a.week == 2 && b.week == 1))
                return false;
            if (a.day != b.day)
                return false;
            if (a.startTime.CompareTo(b.startTime) ==1)
            {
                Period t = a;
                a = b;
                b = t;
            }
            if (b.startTime.CompareTo(a.startTime) >= 0 && b.startTime.CompareTo(a.endTime) <0)
                return true;
            return false;
        }
    }
}
